package com.czk.model.iterator;

import java.util.Iterator;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/5/11 20:32
 */
public class ComputerCollege implements College {
    private Department[] departments;
    private int numberOfDepartment=0;//

    public ComputerCollege(){
        // 初始化
        departments=new Department[5];
        addDepartment("java","java");
        addDepartment("c++","c++");
        addDepartment("大数据","大数据");
        addDepartment("php","php");
    }
    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
       Department department= new Department(name,desc);
       departments[numberOfDepartment]=department;
       numberOfDepartment++;
    }
    // 创建迭代器
    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }
}
